<?php
/**
 * Created by PhpStorm.
 * User: Jerry
 * Date: 2017/3/15
 * Time: 16:50
 */

namespace SDXApi\Controller;


use SDXApi\Service\AlbumService;
use SDXApi\Service\UserBehavior;

/**
 * Class AlbumController
 * @package SDXApi\Controller
 */
class AlbumController extends AppController
{
	/**
	 * Created by Jerry
	 * @param string $appToken
	 * @param string $appTime
	 */
	public function _initialize($appToken, $appTime)
	{
		parent::_initialize($appToken, $appTime); // TODO: Change the autogenerated stub
	}

	/**
	 * Created by Jerry
	 */
	public function get_album()
	{
		$albumId = I('post.album_id', 0, 'int');
		$userId = I('post.uid', 0, 'int');
		$wid = I('post.wid', 8, 'int');

		$is_app =  I('post.is_app', 0, 'int');
		$is_hd = I('post.IS_HD', null, 'int');
		$is_h5 = I('post.is_h5', 0, 'int');

		if (empty($albumId)) {
			returnApiError('非法请求');
		}

		$albumService = new AlbumService();
		$albumService->userId = $userId;
		$albumService->wid = $wid;
		$albumData = $albumService->getAlbumData($albumId);

		if (empty($albumData)) {
			returnApiError('暂无数据');
		}

        //添加行为
        $user_bevavior = new UserBehavior();
        $user_bevavior->add_browse($userId, 22, $albumId, $albumData['name']);

		returnApiSuccess($albumData);
	}
}